home *** CD-ROM | disk | FTP | other *** search
- class actionscript.Interface extends MovieClip
- {
- var game;
- var info_txt;
- var info2_txt;
- var w2;
- var w3;
- var w4;
- var w5;
- var upgrade_btn;
- var sell_btn;
- var life_btn;
- var _w1Desc;
- var _w2Desc;
- var _w3Desc;
- var _w4Desc;
- var _w5Desc;
- var _weaponSelected;
- var _money;
- var _lives;
- var _score;
- var _hours;
- var _minutes;
- var _seconds;
- var w1;
- var money_txt;
- var lives_txt;
- var level_txt;
- var score_txt;
- var minutes_txt;
- var hours_txt;
- var menu_btn;
- var credits_mc;
- var lives_mc;
- var level_mc;
- var time_mc;
- var pause_btn;
- var sfx_btn;
- var music_btn;
- var seconds_txt;
- function Interface()
- {
- super();
- this._x = 460;
- this._y = 0;
- this.game = this._parent;
- this.info_txt.html = this.info2_txt.html = true;
- this.info_txt.wordWrap = this.info2_txt.html = true;
- this.info_txt.multiline = this.info2_txt.html = true;
- this.info2_txt.html = this.info2_txt.html = true;
- this.info2_txt.wordWrap = this.info2_txt.html = true;
- this.info2_txt.multiline = this.info2_txt.html = true;
- this.init();
- }
- function init()
- {
- this.w2.gotoAndStop("locked");
- this.w3.gotoAndStop("locked");
- this.w4.gotoAndStop("locked");
- this.w5.gotoAndStop("locked");
- this.upgrade_btn.gotoAndStop("idle");
- this.sell_btn.gotoAndStop("idle");
- this.life_btn.gotoAndStop("idle");
- var _loc3_ = this.game.textMessages;
- this._w1Desc = _loc3_._beansDesc;
- this._w2Desc = _loc3_._friesDesc;
- this._w3Desc = _loc3_._pepsiDesc;
- this._w4Desc = _loc3_._wingsDesc;
- this._w5Desc = _loc3_._burgerDesc;
- this._weaponSelected = false;
- this._money = this.game._money;
- this._lives = this.game._lives;
- this._score = 0;
- this._hours = 0;
- this._minutes = 0;
- this._seconds = 0;
- var _loc2_ = 1;
- while(_loc2_ <= 5)
- {
- this["w" + _loc2_]._active = false;
- _loc2_ = _loc2_ + 1;
- }
- this.life_btn._active = false;
- _loc2_ = 2;
- while(_loc2_ <= 5)
- {
- this["w" + _loc2_]._available = false;
- _loc2_ = _loc2_ + 1;
- }
- this.w1._available = true;
- this.setText(this.money_txt,this._money);
- this.setText(this.lives_txt,this._lives);
- this.setText(this.level_txt,this.game._lvl);
- this.setText(this.score_txt,this._score);
- this.setText(this.minutes_txt,"00");
- this.setText(this.hours_txt,"00");
- this.initButtonStates();
- this.checkButtons();
- }
- function initButtonStates()
- {
- var _loc2_ = this.game.textMessages;
- this.w1.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w1);
- this.w1.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w1);
- this.w1.useHandCursor = true;
- this.w2.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w2);
- this.w2.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w2);
- this.w2.useHandCursor = true;
- this.w3.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w3);
- this.w3.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w3);
- this.w3.useHandCursor = true;
- this.w4.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w4);
- this.w4.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w4);
- this.w4.useHandCursor = true;
- this.w5.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w5);
- this.w5.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w5);
- this.w5.useHandCursor = true;
- this.life_btn.onPress = actionscript.Proxy.create(this,this.addLife);
- this.life_btn.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.life_btn);
- this.life_btn.useHandCursor = true;
- this.menu_btn.onPress = actionscript.Proxy.create(this,this.callMenu);
- this.menu_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._menuOver);
- this.menu_btn.useHandCursor = true;
- this.credits_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._creditsOver);
- this.lives_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._livesOver);
- this.level_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._levelOver);
- this.time_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._timeOver);
- this.upgrade_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._upgradeOver);
- this.upgrade_btn.useHandCursor = true;
- this.sell_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._sellOver);
- this.sell_btn.useHandCursor = true;
- this.pause_btn.onPress = actionscript.Proxy.create(this,this.pauseResume);
- this.pause_btn.useHandCursor = true;
- this.sfx_btn.onPress = actionscript.Proxy.create(this,this.toggleSfx);
- this.sfx_btn.useHandCursor = true;
- this.music_btn.onPress = actionscript.Proxy.create(this,this.toggleMusic);
- this.music_btn.useHandCursor = true;
- for(var _loc3_ in this)
- {
- if(this[_loc3_] instanceof MovieClip && this[_loc3_] != this._parent && this[_loc3_].onRollOver != undefined)
- {
- this[_loc3_].onRollOut = actionscript.Proxy.create(this,this.setText,this.info_txt,"");
- }
- }
- }
- function toggleSfx()
- {
- if(this.game._sfxOn)
- {
- this.sfx_btn.gotoAndStop("off");
- this.game._sfxOn = false;
- }
- else
- {
- this.sfx_btn.gotoAndStop("on");
- this.game._sfxOn = true;
- }
- }
- function toggleMusic()
- {
- if(this.game._musicOn)
- {
- stopAllSounds();
- this.music_btn.gotoAndStop("off");
- this.game._musicOn = false;
- }
- else
- {
- this.game.startSound(this.game._loopSoundName,true);
- this.music_btn.gotoAndStop("on");
- this.game._musicOn = true;
- }
- }
- function pauseResume()
- {
- if(this.game._gamePaused)
- {
- this.pause_btn.gotoAndStop("pause");
- this.game.resumeGame();
- }
- else
- {
- this.pause_btn.gotoAndStop("resume");
- this.game.pauseGame();
- var _loc2_ = this.game.textMessages;
- this.menu_btn.onPress = actionscript.Proxy.create(this,this.callMenu);
- this.menu_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._menuOver);
- this.pause_btn.onPress = actionscript.Proxy.create(this,this.pauseResume);
- this.pause_btn.useHandCursor = true;
- this.menu_btn.useHandCursor = true;
- }
- }
- function resumeGame()
- {
- }
- function deleteButtonStates()
- {
- for(var _loc2_ in this)
- {
- if(this[_loc2_] instanceof MovieClip && this[_loc2_] != this._parent)
- {
- this[_loc2_].useHandCursor = false;
- this[_loc2_].onRelease = undefined;
- this[_loc2_].onPress = undefined;
- this[_loc2_].onRollOver = undefined;
- this[_loc2_].onRollOut = undefined;
- }
- }
- }
- function callMenu()
- {
- this.pause_btn.onPress = undefined;
- this.pause_btn.gotoAndStop("pause");
- this.game.callMenu();
- }
- function showInfo(mW)
- {
- var _loc2_ = this.game.wValue;
- var _loc3_ = this.game.unlockLevel;
- if(!mW._available && mW != this.life_btn)
- {
- switch(mW)
- {
- case this.w2:
- this.setText(this.info_txt,"Fries: " + _loc2_.Fries1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Fries + "!");
- break;
- case this.w3:
- this.setText(this.info_txt,"Pepsi: " + _loc2_.Pepsi1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Pepsi + "!");
- break;
- case this.w4:
- this.setText(this.info_txt,"Chicken Wings: " + _loc2_.Wings1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Wings + "!");
- break;
- case this.w5:
- this.setText(this.info_txt,"Big Daddy Burger: " + _loc2_.Burger1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Burger + "!");
- }
- return undefined;
- }
- switch(mW)
- {
- case this.w1:
- this.setText(this.info_txt,"Beans: " + _loc2_.Beans1 + " CREDITS <br>" + this._w1Desc);
- break;
- case this.w2:
- this.setText(this.info_txt,"Fries: " + _loc2_.Fries1 + " CREDITS<br>" + this._w2Desc);
- break;
- case this.w3:
- this.setText(this.info_txt,"Pepsi: " + _loc2_.Pepsi1 + " CREDITS<br>" + this._w3Desc);
- break;
- case this.w4:
- this.setText(this.info_txt,"Chicken Wings: " + _loc2_.Wings1 + " CREDITS<br>" + this._w4Desc);
- break;
- case this.w5:
- this.setText(this.info_txt,"Big Daddy Burger: " + _loc2_.Burger1 + " CREDITS<br>" + this._w5Desc);
- break;
- case this.life_btn:
- if(this._lives < this.game._maxLives)
- {
- this.setText(this.info_txt,"LIFE:<br>Buy 1 life for " + this.game._lifeValue + " CREDITS.");
- }
- else
- {
- this.setText(this.info_txt,"Maximum " + this.game._maxLives + " lives.");
- }
- }
- }
- function addSeconds()
- {
- this._seconds = this._seconds + 1;
- if(this._seconds == 60)
- {
- this._seconds = 0;
- this._minutes = this._minutes + 1;
- if(this._minutes == 60)
- {
- this._minutes = 0;
- this._hours = this._hours + 1;
- if(this._hours < 10)
- {
- this.setText(this.hours_txt,"0" + this._hours);
- }
- else
- {
- this.setText(this.hours_txt,this._hours);
- }
- }
- }
- if(this._minutes < 10)
- {
- this.setText(this.minutes_txt,"0" + this._minutes);
- }
- else
- {
- this.setText(this.minutes_txt,this._minutes);
- }
- if(this._seconds < 10)
- {
- this.setText(this.seconds_txt,"0" + this._seconds);
- }
- else
- {
- this.setText(this.seconds_txt,this._seconds);
- }
- }
- function createWeapon(mW)
- {
- if(this.game.currentWeapon != undefined)
- {
- this.closeWeaponOptions(this.game.currentWeapon);
- }
- if(this.game._draggingWeapon || this.game._stopped || !mW._active || !mW._available)
- {
- return undefined;
- }
- switch(mW)
- {
- case this.w1:
- this.game.attachMovie("Weapon","Beans" + this.game.w1_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Beans"});
- this.game.w1_counter = this.game.w1_counter + 1;
- this.game._draggingWeapon = true;
- break;
- case this.w2:
- this.game.attachMovie("Weapon","Fries" + this.game.w2_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Fries"});
- this.game.w2_counter = this.game.w2_counter + 1;
- this.game._draggingWeapon = true;
- break;
- case this.w3:
- this.game.attachMovie("Weapon","Pepsi" + this.game.w3_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Pepsi"});
- this.game.w3_counter = this.game.w3_counter + 1;
- this.game._draggingWeapon = true;
- break;
- case this.w4:
- this.game.attachMovie("Weapon","Wings" + this.game.w4_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Wings"});
- this.game.w4_counter = this.game.w4_counter + 1;
- this.game._draggingWeapon = true;
- break;
- case this.w5:
- this.game.attachMovie("Weapon","Burger" + this.game.w5_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Burger"});
- this.game.w5_counter = this.game.w5_counter + 1;
- this.game._draggingWeapon = true;
- }
- }
- function attachWeaponOptions(mWeapon)
- {
- this.sell_btn.gotoAndStop("normal");
- this.sell_btn.onPress = actionscript.Proxy.create(this,this.sell,mWeapon);
- this.checkButtons();
- }
- function upgrade(mW)
- {
- if(mW._upgradeCost <= this._money && mW._wLevel < 3)
- {
- this.addSubtractMoney(- mW._upgradeCost);
- mW.upgradeWeapon();
- }
- else if(mW._upgradeCost > this._money)
- {
- this.setText(this.info_txt,"You don\'t have enough money to upgrade. You need " + mW._upgradeCost + " CREDITS");
- }
- else if(mW._wLevel >= 3)
- {
- this.setText(this.info_txt,"You reached the max level for this weapon");
- }
- }
- function sell(mW)
- {
- mW.sellWeapon();
- }
- function closeWeaponOptions(mW)
- {
- this.initButtonStates();
- this.sell_btn.gotoAndStop("idle");
- this.sell_btn.onPress = undefined;
- this.upgrade_btn.gotoAndStop("idle");
- this.upgrade_btn.onPress = undefined;
- this.game.currentWeapon = undefined;
- this.game._SellUpgrade = false;
- mW.radius._visible = false;
- this.checkButtons();
- }
- function setText(tTextField, nText)
- {
- tTextField.htmlText = nText.toString();
- }
- function addSubtractMoney(nAmount)
- {
- this._money += nAmount;
- this.setText(this.money_txt,this._money);
- this.checkButtons();
- }
- function addScore(nAmount)
- {
- this._score = Math.round(this._score + nAmount);
- this.setText(this.score_txt,this._score);
- }
- function loseLife()
- {
- this._lives = this._lives - 1;
- if(this._lives <= 0)
- {
- this.game.gameOver();
- }
- this.setText(this.lives_txt,this._lives);
- }
- function addLife()
- {
- if(!this.life_btn._active)
- {
- return undefined;
- }
- if(this._lives < this.game._maxLives)
- {
- this._lives = this._lives + 1;
- this.setText(this.lives_txt,this._lives);
- this.addSubtractMoney(- this.game._lifeValue);
- }
- return undefined;
- }
- function checkButtons()
- {
- if(this.w1._active && this._money < this.game.wValue.Beans1)
- {
- this.w1.gotoAndStop("idle");
- this.w1._active = false;
- }
- else if(!this.w1._active && this._money >= this.game.wValue.Beans1)
- {
- this.w1.gotoAndStop("normal");
- this.w1._active = true;
- }
- if(this.w2._active && this._money < this.game.wValue.Fries1)
- {
- this.w2.gotoAndStop("idle");
- this.w2._active = false;
- }
- else if(!this.w2._active && this._money >= this.game.wValue.Fries1 && this.w2._available)
- {
- this.w2.gotoAndStop("normal");
- this.w2._active = true;
- }
- else if(!this.w2._active && this._money < this.game.wValue.Fries1 && this.w2._available)
- {
- this.w2.gotoAndStop("idle");
- }
- if(this.w3._active && this._money < this.game.wValue.Pepsi1)
- {
- this.w3.gotoAndStop("idle");
- this.w3._active = false;
- }
- else if(!this.w3._active && this._money >= this.game.wValue.Pepsi1 && this.w3._available)
- {
- this.w3.gotoAndStop("normal");
- this.w3._active = true;
- }
- else if(!this.w3._active && this._money < this.game.wValue.Pepsi1 && this.w3._available)
- {
- this.w3.gotoAndStop("idle");
- }
- if(this.w4._active && this._money < this.game.wValue.Wings1)
- {
- this.w4.gotoAndStop("idle");
- this.w4._active = false;
- }
- else if(!this.w4._active && this._money >= this.game.wValue.Wings1 && this.w4._available)
- {
- this.w4.gotoAndStop("normal");
- this.w4._active = true;
- }
- else if(!this.w4._active && this._money < this.game.wValue.Wings1 && this.w4._available)
- {
- this.w4.gotoAndStop("idle");
- }
- if(this.w5._active && this._money < this.game.wValue.Burger1)
- {
- this.w5.gotoAndStop("idle");
- this.w5._active = false;
- }
- else if(!this.w5._active && this._money >= this.game.wValue.Burger1 && this.w5._available)
- {
- this.w5.gotoAndStop("normal");
- this.w5._active = true;
- }
- else if(!this.w5._active && this._money < this.game.wValue.Burger1 && this.w5._available)
- {
- this.w5.gotoAndStop("idle");
- }
- if(this.life_btn._active && this._money < this.game._lifeValue)
- {
- this.life_btn.gotoAndStop("idle");
- this.life_btn._active = false;
- }
- else if(!this.life_btn._active && this._money >= this.game._lifeValue)
- {
- this.life_btn.gotoAndStop("normal");
- this.life_btn._active = true;
- }
- if(this.game._SellUpgrade)
- {
- if(this.game.currentWeapon._upgradeCost <= this._money && this.game.currentWeapon._wLevel < 3)
- {
- this.upgrade_btn.gotoAndStop("normal");
- this.upgrade_btn.onPress = actionscript.Proxy.create(this,this.upgrade,this.game.currentWeapon);
- }
- else if(this.game.currentWeapon._upgradeCost > this._money)
- {
- this.upgrade_btn.gotoAndStop("idle");
- this.upgrade_btn.onPress = undefined;
- }
- if(this.game.currentWeapon._wLevel == 3)
- {
- this.upgrade_btn.gotoAndStop("idle");
- this.upgrade_btn.onPress = undefined;
- }
- }
- }
- }
-